package com.stillalive.springbootbooksystem.config;

import com.stillalive.springbootbooksystem.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor = new LoginInterceptor();
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 使用拦截器对象来针对指定路径进行拦截
        registry.addInterceptor(loginInterceptor)
                // 针对book目录下的界面访问进行拦截
                .addPathPatterns("/book/**");
    }
}
